trying URL 'http://cran.us.r-project.org/bin/macosx/contrib/4.0/maps_3.3.0.tgz'
Content type 'application/x-gzip' length 3687860 bytes (3.5 MB)
==================================================
downloaded 3.5 MB
The downloaded binary packages are in
/var/folders/gs/080wb67j58df5y8ccjf53yw00000gn/T//Rtmp9OH1LM/downloaded_packages
trying URL 'http://cran.us.r-project.org/bin/macosx/contrib/4.0/tmap_3.3-1.tgz'
Content type 'application/x-gzip' length 3585561 bytes (3.4 MB)
==================================================
downloaded 3.4 MB
The downloaded binary packages are in
/var/folders/gs/080wb67j58df5y8ccjf53yw00000gn/T//Rtmp9OH1LM/downloaded_packages
trying URL 'http://cran.us.r-project.org/bin/macosx/contrib/4.0/rgeos_0.5-5.tgz'
Content type 'application/x-gzip' length 8537441 bytes (8.1 MB)
==================================================
downloaded 8.1 MB
The downloaded binary packages are in
/var/folders/gs/080wb67j58df5y8ccjf53yw00000gn/T//Rtmp9OH1LM/downloaded_packages
library(educationdata)
# Test Run with using get_education_data
# data <- get_education_data(level = "college-university",
# source = "ipeds",
# topic = "directory",
# filters = list(year = 2019))
# data
# Scorecard data - 2019
sc <- read_csv('2019_College_Scorecard_Valid_Admissions_Data.csv')
sc
## change projection of sc data
sc <- sc %>%
dplyr::mutate(uni_rank = case_when(
ADM_RATE < 0.05 ~ 'elite',
ADM_RATE < 0.2 ~ 'highly selective',
ADM_RATE < 0.3 ~ 'more selective',
ADM_RATE < 0.5 ~ 'selective',
ADM_RATE < 0.7 ~ 'less selective',
TRUE ~ 'not selective')) %>% mutate(uni_rank = factor(uni_rank, levels=c('not selective', 'less selective', 'selective', 'more selective', 'highly selective', 'elite')))
First we are going to try to present this pattern for different tiers of universities (admission rate as well as debt)
# Remove PrivacySuppressed Records and transform Debt Median into a numeric value - we can also do this on the main sc df
sc$DEBT_MDN[is.na(sc$DEBT_MDN)] <- 0;
m <- sc %>% subset(DEBT_MDN !='PrivacySuppressed') %>% transform(DEBT_MDN = as.numeric(DEBT_MDN)) %>%
ggplot(., aes(x=ADM_RATE, y=DEBT_MDN,color=uni_rank)) +
geom_point() +
geom_smooth(color='#EA4F88', se = FALSE) +
theme_ipsum(base_size = 10, axis_title_size = 12, plot_title_size=14) +
scale_color_viridis_d()+
theme(
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
scale_y_discrete(limits=c(0,10000,20000,30000), labels=c('0','10','20','30')) +
labs(x='Admissions Rate', y='Median Loan Amount per Student\n(thousands)',
title='Student Debt and Admissions Rate',
color='Selectivity')
Continuous limits supplied to discrete scale.
Did you mean `limits = factor(...)` or `scale_*_continuous()`?
m
ipeds15 <- get_education_data(level = "college-university",
source = "ipeds",
topic = "grad-rates-pell",
filters = list(year = 2015))
ipeds15
#Process the data
sc_time <- read_csv('2010_2019_student_debt.csv')
Missing column names filled in: 'X1' [1]
── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────
cols(
.default = col_double(),
INSTNM = col_character(),
CITY = col_character(),
STABBR = col_character(),
ZIP = col_character(),
UNEMP_RATE = col_logical(),
DEBT_MDN = col_character(),
MN_EARN_WNE_P10 = col_logical(),
MD_EARN_WNE_P10 = col_logical(),
School = col_logical(),
State = col_logical(),
True = col_character(),
ADM_RATE_ALL_1 = col_character()
)
ℹ Use `spec()` for the full column specifications.
28660 parsing failures.
row col expected actual file
3223 UNITID a double Community College '2010_2019_student_debt.csv'
3223 School 1/0/T/F/TRUE/FALSE Kenai Peninsula College '2010_2019_student_debt.csv'
3223 State 1/0/T/F/TRUE/FALSE Alaska '2010_2019_student_debt.csv'
3224 UNITID a double Community College '2010_2019_student_debt.csv'
3224 School 1/0/T/F/TRUE/FALSE Kodiak College '2010_2019_student_debt.csv'
.... ...... .................. ....................... ............................
See problems(...) for more details.
sc_time<- sc_time %>% subset(DEBT_MDN !='PrivacySuppressed') %>%
transform(DEBT_MDN = as.numeric(DEBT_MDN)) %>%
dplyr::mutate(DEBT_MDN = ifelse(is.na(DEBT_MDN), 0, DEBT_MDN))
# Additions of States df from Tigris File
library(tigris)
To enable
caching of data, set `options(tigris_use_cache = TRUE)` in your R script or .Rprofile.
states <- states(cb = TRUE)
|
| | 0%
|
|= | 1%
|
|== | 1%
|
|== | 2%
|
|=== | 2%
|
|=== | 3%
|
|==== | 3%
|
|==== | 4%
|
|===== | 4%
|
|====== | 5%
|
|======= | 6%
|
|======== | 7%
|
|========= | 8%
|
|========== | 8%
|
|========== | 9%
|
|=========== | 9%
|
|=========== | 10%
|
|============ | 10%
|
|============= | 11%
|
|============== | 12%
|
|=============== | 13%
|
|================ | 14%
|
|================= | 14%
|
|================= | 15%
|
|=================== | 16%
|
|==================== | 17%
|
|===================== | 17%
|
|===================== | 18%
|
|====================== | 18%
|
|====================== | 19%
|
|======================= | 19%
|
|========================= | 21%
|
|=========================== | 22%
|
|============================ | 23%
|
|============================= | 24%
|
|=============================== | 26%
|
|=============================== | 27%
|
|================================= | 28%
|
|================================== | 29%
|
|===================================== | 31%
|
|====================================== | 32%
|
|======================================= | 33%
|
|========================================= | 34%
|
|========================================= | 35%
|
|=========================================== | 36%
|
|============================================= | 38%
|
|================================================= | 42%
|
|================================================== | 43%
|
|======================================================= | 46%
|
|======================================================= | 47%
|
|======================================================== | 48%
|
|=========================================================== | 50%
|
|============================================================ | 51%
|
|============================================================== | 53%
|
|=============================================================== | 53%
|
|================================================================ | 55%
|
|================================================================== | 56%
|
|==================================================================== | 58%
|
|====================================================================== | 59%
|
|======================================================================== | 61%
|
|========================================================================== | 63%
|
|=========================================================================== | 64%
|
|============================================================================ | 65%
|
|============================================================================== | 66%
|
|================================================================================ | 68%
|
|================================================================================== | 69%
|
|==================================================================================== | 71%
|
|========================================================================================= | 76%
|
|============================================================================================= | 79%
|
|=================================================================================================== | 84%
|
|====================================================================================================== | 87%
|
|======================================================================================================= | 87%
|
|======================================================================================================== | 88%
|
|========================================================================================================== | 89%
|
|============================================================================================================= | 92%
|
|============================================================================================================== | 93%
|
|================================================================================================================ | 95%
|
|================================================================================================================== | 96%
|
|===================================================================================================================== | 99%
|
|======================================================================================================================| 100%
sc_time
sc_time_year <- sc_time %>% group_by()
# States
states_10 <- states %>%
inner_join(sc_time, by=c(STUSPS='STABBR'))
popup1 <- paste("State:",states$NAME,"<br/>",
"Population:",states$population,"<br/>",
"Successful Projects / Population:",states$scaled_success,"<br/>")
#used 'success' measures.
m <- leaflet(states) %>% addProviderTiles("CartoDB.Positron") %>%
addPolygons(fillColor = ~pal(states$scaled_success),
color = "white",
weight = 0.5,
fillOpacity = 0.7,
highlight = highlightOptions(
weight = 5,
color = "#666",
fillOpacity = 0.7,
bringToFront = TRUE),
popup=popup1) %>%
addLegend(position = "bottomleft",pal = pal, values = c(min(states$scaled_success),max(states$scaled_success)),title = "Successful Kickstarter Projects\n (scaled by state)") %>%
setView(-98.5795, 39.8282, zoom=3)
Error in setView(., -98.5795, 39.8282, zoom = 3) :
could not find function "setView"